home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CUJ9206.ARJ / 1006018A < prev    next >
Text File  |  1992-06-02  |  352b  |  17 lines

  1. /* calloc function */
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void *(calloc)(size_t nelem, size_t size)
  6.         {       /* allocate a data object on the heap and clear it 
  7. */
  8.         const size_t n = nelem * size;
  9.         char *p = (char *)malloc(n);
  10.  
  11.         if (p)
  12.                 memset(p, '\0', n);
  13.         return (p);
  14.         }
  15.  
  16.  
  17.